import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '姓名',
    align:"center",
    dataIndex: 'custName'
   },
   {
    title: '电话',
    align:"center",
    dataIndex: 'phone'
   },
   {
    title: '所属区域',
    align:"center",
    dataIndex: 'area',
   },
   {
    title: '家庭住址',
    align:"center",
    dataIndex: 'custAddr'
   },
   {
    title: '安装日期',
    align:"center",
    dataIndex: 'installDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '产品型号',
    align:"center",
    dataIndex: 'deviceModel'
   },
   {
    title: '产品型号2',
    align:"center",
    dataIndex: 'mainBus'
   },
   {
    title: '销售渠道',
    align:"center",
    dataIndex: 'operation'
   },
   {
    title: '备注1',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '备注2',
    align:"center",
    dataIndex: 'position'
   },
   {
    title: '备注3',
    align:"center",
    dataIndex: 'bank'
   },
   {
    title: '备注4',
    align:"center",
    dataIndex: 'money'
   },
   {
    title: '下次更换日期',
    align:"center",
    dataIndex: 'nextReplaceDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "姓名",
      field: 'custName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "电话",
      field: 'phone',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "所属区域",
      field: 'area',
      component: 'JAreaLinkage',
      componentProps: {
        saveCode: 'region',
      },
      //colProps: {span: 6},
 	},
	{
      label: "家庭住址",
      field: 'custAddr',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "安装日期",
      field: "installDate",
      component: 'RangePicker',
      componentProps: {
        valueType: 'Date',
      },
      //colProps: {span: 6},
	},
     {
      label: "下次更换日期",
      field: "nextReplaceDate",
      component: 'RangePicker',
      componentProps: {
        valueType: 'Date',
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'custName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入姓名!'},
          ];
     },
  },
  {
    label: '电话',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入电话!'},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '所属区域',
    field: 'area',
	defaultValue: ['520000','520100','520101'],
    component: 'JAreaLinkage',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属区域!'},
          ];
     },
  },
  {
    label: '家庭住址',
    field: 'custAddr',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入家庭住址!'},
          ];
     },
  },
  {
    label: '安装日期',
    field: 'installDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '产品型号',
    field: 'deviceModel',
    component: 'Input',
  },
  {
    label: '产品型号2',
    field: 'mainBus',
    component: 'Input',
  },
  {
    label: '销售渠道',
    field: 'operation',
    component: 'Input',
  },
  {
    label: '备注1',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '备注2',
    field: 'position',
    component: 'Input',
  },
  {
    label: '备注3',
    field: 'bank',
    component: 'Input',
  },
  {
    label: '备注4',
    field: 'money',
    component: 'Input',
  },
  {
    label: '下次更换日期',
    field: 'nextReplaceDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  custName: {title: '姓名',order: 0,view: 'text', type: 'string',},
  phone: {title: '电话',order: 1,view: 'text', type: 'string',},
  area: {title: '所属区域',order: 2,view: 'pca', type: 'string',},
  custAddr: {title: '家庭住址',order: 3,view: 'text', type: 'string',},
  installDate: {title: '安装日期',order: 4,view: 'date', type: 'string',},
  deviceModel: {title: '产品型号',order: 5,view: 'text', type: 'string',},
  mainBus: {title: '产品型号2',order: 6,view: 'text', type: 'string',},
  operation: {title: '销售渠道',order: 7,view: 'text', type: 'string',},
  remark: {title: '备注1',order: 8,view: 'text', type: 'string',},
  position: {title: '备注2',order: 9,view: 'text', type: 'string',},
  bank: {title: '备注3',order: 10,view: 'text', type: 'string',},
  money: {title: '备注4',order: 11,view: 'text', type: 'string',},
  nextReplaceDate: {title: '下次更换日期',order: 12,view: 'date', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}